﻿using System;
using System.Collections.Generic;
using EnvDTE;
using EnvDTE80;


namespace VsTortoiseSVN.Commands
{
    public class SolutionExplorerSelectedItemsOpenModifiedFile : SolutionExplorerSelectedItemsBase
    {
        private Dialogs.OpenModifiedDocumentDialog _dialog
        {
            get;
            set;
        }

        public SolutionExplorerSelectedItemsOpenModifiedFile(DTE2 application, string name, string caption, string tooltip, int bitmapId, Dialogs.OpenModifiedDocumentDialog dialogInstance)
            : base(application, name, caption, tooltip, bitmapId)
        {
            _dialog = dialogInstance;
        }

        protected override vsCommandStatus QueryContextSensitiveStatus()
        {
            // When only one file is selected, opening "Open Modified File" dialog makes no sense.
            return vsCommandStatus.vsCommandStatusUnsupported;
        }

        protected override vsCommandStatus QueryContextInsensitiveStatus()
        {
            return vsCommandStatus.vsCommandStatusSupported | vsCommandStatus.vsCommandStatusEnabled;
        }

        public override bool Exec()
        {
            List<string> fullNames = GetFullNames();
            _dialog.ShowDialog(fullNames);
            return true;
        }
    }
}
